package com.ruoyi.accountant.job;

import com.ruoyi.accountant.service.TransactionDetailService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

/***
 * 清理数据任务
 */
public class CleanJob extends QuartzJobBean {

    private Logger logger = LoggerFactory.getLogger(CleanJob.class);

    @Autowired
    private TransactionDetailService transactionDetailService;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        // 如果删除超过90天，清理删除的交易
        logger.info("开始清理交易记录");
        int i = transactionDetailService.deleteOverDeletedDays();
        logger.info("交易记录清理数："+i);
    }
}
